home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
WINPROGS
/
UPC12BS1.ZIP
/
UUCICO
/
ULIBOS2.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-03
|
41KB
|
1,298 lines
/*--------------------------------------------------------------------*/
/* u l i b o s 2 . c */
/* */
/* OS/2 serial port support for UUCICO */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* Changes Copyright (c) 1989-1993 by Kendra Electronic */
/* Wonderworks. */
/* */
/* All rights reserved except those explicitly granted by the */
/* UUPC/extended license agreement. */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* RCS Information */
/*--------------------------------------------------------------------*/
/*
* $Id: ulibos2.c 1.23 1993/10/03 22:09:09 ahd Exp $
* $Log: ulibos2.c $
* Revision 1.23 1993/10/03 22:09:09 ahd
* Use unsigned long to display speed
*
* Revision 1.22 1993/10/01 01:17:44 ahd
* Drop unneeded special case for port in use message
*
* Revision 1.21 1993/09/29 05:25:21 ahd
* Don't die after duplicate port close
*
* Revision 1.20 1993/09/29 04:52:03 ahd
* Use unique handler for port suspending
*
* Revision 1.19 1993/09/27 04:04:06 ahd
* Normalize references to modem speed to avoid incorrect displays
*
* Revision 1.18 1993/09/25 03:07:56 ahd
* Convert to standard OS/2 error message call
*
* Revision 1.17 1993/09/24 03:43:27 ahd
* Use OS/2 error message routine
*
* Revision 1.16 1993/09/21 01:42:13 ahd
* Use standard MAXPACK limit for save buffer size
*
* Revision 1.15 1993/09/20 04:46:34 ahd
* OS/2 2.x support (BC++ 1.0 support)
* TCP/IP support from Dave Watt
* 't' protocol support
*
* Revision 1.14 1993/05/30 15:25:50 ahd
* Multiple driver support
*
* Revision 1.13 1993/05/30 00:08:03 ahd
* Multiple communications driver support
* Delete trace functions
*
* Revision 1.12 1993/05/09 03:41:47 ahd
* Make swrite accept constant input strings
*
* Revision 1.11 1993/04/11 00:34:11 ahd
* Global edits for year, TEXT, etc.
*
* Revision 1.10 1993/04/10 21:25:16 dmwatt
* Add Windows/NT support
*
* Revision 1.9 1993/04/05 04:32:19 ahd
* Additional traps for modem dropping out
*
* Revision 1.8 1993/04/04 04:57:01 ahd
* Add configurable OS/2 priority values
*
* Revision 1.7 1992/12/30 13:02:55 dmwatt
* Dual path for Windows/NT and OS/2
*
* Revision 1.6 1992/12/11 12:45:11 ahd
* Correct RTS handshake
*
* Revision 1.5 1992/12/04 01:00:27 ahd
* Add copyright message, reblock other comments
*
* Revision 1.4 1992/11/29 22:09:10 ahd
* Add new define for BC++ OS/2 build
*
* Revision 1.3 1992/11/19 03:00:39 ahd
* drop rcsid
*
* Revision 1.2 1992/11/15 20:11:48 ahd
* Add English display of modem status and error bits
*
*/
/*--------------------------------------------------------------------*/
/* System include files */
/*--------------------------------------------------------------------*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <io.h>
#include <time.h>
/*--------------------------------------------------------------------*/
/* OS/2 include files */
/*--------------------------------------------------------------------*/
#define INCL_DOSDEVIOCTL
#define INCL_BASE
#define INCL_NOPMAPI
#include <os2.h>
#include <limits.h>
#ifndef __OS2__
typedef USHORT APIRET ; // Define older API return type
#endif
/*--------------------------------------------------------------------*/
/* UUPC/extended include files */
/*--------------------------------------------------------------------*/
#include "lib.h"
#include "ulib.h"
#include "ssleep.h"
#include "catcher.h"
#include "pos2err.h"
#include "commlib.h"
#include "usrcatch.h"
/*--------------------------------------------------------------------*/
/* Global variables */
/*--------------------------------------------------------------------*/
currentfile();
static boolean carrierDetect = FALSE; /* Modem is not connected */
static boolean hangupNeeded = FALSE;
static unsigned short currentSpeed = 0;
#define FAR_NULL ((PVOID) 0L)
/*--------------------------------------------------------------------*/
/* Definitions of control structures for DOS API */
/*--------------------------------------------------------------------*/
static HFILE com_handle;
static struct _LINECONTROL com_attrib;
static struct _MODEMSTATUS com_signals;
static struct _DCBINFO com_dcbinfo;
static void ShowError( const USHORT status );
static void ShowModem( const BYTE status );
/*--------------------------------------------------------------------*/
/* n o p e n l i n e */
/* */
/* Open the serial port for I/O */
/*--------------------------------------------------------------------*/
int nopenline(char *name, BPS baud, const boolean direct )
{
APIRET rc;
USHORT com_error;
#ifdef __OS2__
ULONG ParmLengthInOut;
ULONG DataLengthInOut;
ULONG action;
#else
USHORT action;
#endif
if (portActive) /* Was the port already active? */
closeline(); /* Yes --> Shutdown it before open */
#ifdef UDEBUG
printmsg(15, "nopenline: %s, %lu", name, baud);
#endif
/*--------------------------------------------------------------------*/
/* Validate the port format */
/*--------------------------------------------------------------------*/
if (!equaln(name, "COM", 3 ))
{
printmsg(0,"nopenline: Communications port begin with COM, was %s",
name);
panic();
}
/*--------------------------------------------------------------------*/
/* Perform the open */
/*--------------------------------------------------------------------*/
rc = DosOpen( name,
&com_handle,
&action,
0L,
0 ,
FILE_OPEN ,
OPEN_FLAGS_FAIL_ON_ERROR |
OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYREADWRITE, 0L );
/*--------------------------------------------------------------------*/
/* Check the open worked. We translation the common obvious */
/* error of file in use to english, for all other errors are we */
/* report the raw error code. */
/*--------------------------------------------------------------------*/
if ( rc )
{
printOS2error( name, rc );
return TRUE;
}
/*--------------------------------------------------------------------*/
/* Reset any errors on the communications port */
/*--------------------------------------------------------------------*/
#ifdef __OS2__
ParmLengthInOut = 0;
DataLengthInOut = sizeof(com_error);
rc = DosDevIOCtl( com_handle, IOCTL_ASYNC, ASYNC_GETCOMMERROR,
NULL,0L,&ParmLengthInOut,(PVOID) &com_error,sizeof(com_error),
&DataLengthInOut);
#else
rc = DosDevIOCtl( &com_error, FAR_NULL, ASYNC_GETCOMMERROR ,
IOCTL_ASYNC, com_handle);
#endif
if (rc)
{
printmsg(0,
"nopenline: Unable to read errors for %s, erro